#include "ogl/gut/Texture2D.h"
#include "ogl/gut/Dictionary.h"
#include "imgui/gut/Editor.h"
#include "imgui/Editor.h"

using namespace Ogl::Gut;

template <>
bool ImGui::Editor::Edit(const std::string& label, Ogl::Gut::Texture2DDesc1& inst)
{
    int index = 0;

    if (TreeNode(label.c_str(), inst.m_BitFlag, index++))
    {
        EditInst<bool>("Mipmap", *(bool*)&inst);
        ComboInst<SamplerType, SamplerTypeDesc>("SmaplerType", Dictionary::m_SamplerDescs, inst.m_SamplerType);
        EditInst<Ogl::Gut::Image>("Image", inst.m_Image);

        ImGui::TreePop();
    }
    return false;
}

template <>
bool ImGui::Editor::Edit(const std::string& label, Ogl::Gut::Texture2DDesc2& inst)
{
    int index = 0;

    if (TreeNode(label.c_str(), inst.m_BitFlag, index++))
    {
        EditInst<bool>("Mipmap", *(bool*)&inst);
        ComboInst<SamplerType, SamplerTypeDesc>("SmaplerType", Dictionary::m_SamplerDescs, inst.m_SamplerType);
        EditInst<Ogl::Gut::Image::Desc>("Image Desc", inst.m_ImageDesc);

        ImGui::TreePop();
    }
 
    return false;
}

template <>
bool ImGui::Editor::Edit(const std::string& label, Ogl::Gut::Texture2DDesc3& inst)
{
    int index = 0;

    if (TreeNode(label.c_str(), inst.m_BitFlag, index++))
    {
        EditInst<std::string>("origin file", inst.m_Path);
        ImGui::TreePop();
    }

    return false;
}
template <>
bool ImGui::Editor::Edit(const std::string& label, Ogl::Gut::Texture2DDesc& inst)
{
    int index = 0;

    if (Editor::TreeNode(label.c_str(), inst.m_BitFlag, index++))
    {

        ComboInst<Texture2DDescType, Texture2DDescTypeDesc>("Desc Type", Dictionary::m_Texture2DDescTypeDesc, inst.m_Type);
        EditInst("Origin Data", inst.m_Desc1);
        EditInst("Image Desc", inst.m_Desc2);
        EditInst("Origin Data File", inst.m_Desc3);

        ImGui::TreePop();
    }

    return false;
}

template <>
bool ImGui::Editor::Edit(const std::string& label, Ogl::Gut::Texture2D& inst)
{
    int index = 0;
    static ImGui::Gut::Editor m_GutEditor;

    if (Editor::TreeNode(label.c_str(), inst.m_BitFlag, index++))
    {
        m_GutEditor.Show(&inst);
        EditInst<Ogl::Gut::Texture2DDesc>("desc", inst.m_Desc);
        EditInst<Ogl::Gut::Texture>("Texture", inst);
        ImGui::TreePop();
    }

    return false;
}
